{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Title: #Partitioning Into Minimum Number Of Deci-Binary Numbers"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Difficulty: #Medium"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Category Title: #Algorithms"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Tag Slug: #greedy #string"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Name Translated: #贪心 #字符串"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Solution Name: minPartitions"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Translated Title: #十-二进制数的最少数目"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Translated Content:\n",
    "<p>如果一个十进制数字不含任何前导零，且每一位上的数字不是 <code>0</code> 就是 <code>1</code> ，那么该数字就是一个 <strong>十-二进制数</strong> 。例如，<code>101</code> 和 <code>1100</code> 都是 <strong>十-二进制数</strong>，而 <code>112</code> 和 <code>3001</code> 不是。</p>\n",
    "\n",
    "<p>给你一个表示十进制整数的字符串 <code>n</code> ，返回和为 <code>n</code> 的 <strong>十-二进制数 </strong>的最少数目。</p>\n",
    "\n",
    "<p> </p>\n",
    "\n",
    "<p><strong>示例 1：</strong></p>\n",
    "\n",
    "<pre><strong>输入：</strong>n = \"32\"\n",
    "<strong>输出：</strong>3\n",
    "<strong>解释：</strong>10 + 11 + 11 = 32\n",
    "</pre>\n",
    "\n",
    "<p><strong>示例 2：</strong></p>\n",
    "\n",
    "<pre><strong>输入：</strong>n = \"82734\"\n",
    "<strong>输出：</strong>8\n",
    "</pre>\n",
    "\n",
    "<p><strong>示例 3：</strong></p>\n",
    "\n",
    "<pre><strong>输入：</strong>n = \"27346209830709182346\"\n",
    "<strong>输出：</strong>9\n",
    "</pre>\n",
    "\n",
    "<p> </p>\n",
    "\n",
    "<p><strong>提示：</strong></p>\n",
    "\n",
    "<ul>\n",
    "\t<li><code>1 &lt;= n.length &lt;= 10<sup>5</sup></code></li>\n",
    "\t<li><code>n</code> 仅由数字组成</li>\n",
    "\t<li><code>n</code> 不含任何前导零并总是表示正整数</li>\n",
    "</ul>\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Description: [partitioning-into-minimum-number-of-deci-binary-numbers](https://leetcode.cn/problems/partitioning-into-minimum-number-of-deci-binary-numbers/description/)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Solutions: [partitioning-into-minimum-number-of-deci-binary-numbers](https://leetcode.cn/problems/partitioning-into-minimum-number-of-deci-binary-numbers/solutions/)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "test_cases = ['\"32\"', '\"82734\"', '\"27346209830709182346\"']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def minPartitions(self, n: str) -> int:\n",
    "        ans = 0\n",
    "        for i in n:\n",
    "            ans = max(ans,int(i))\n",
    "        return ans"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def minPartitions(self, n: str) -> int:\n",
    "        return max(map(int, str(n)))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def minPartitions(self, n: str) -> int:\n",
    "        # result = 0\n",
    "        # for c in n:\n",
    "        #     result = max(result, int(c))\n",
    "        #     if(result == 9):\n",
    "        #         break\n",
    "        # return result\n",
    "        for v in range(9,0,-1):\n",
    "            if(str(v) in n):\n",
    "                return v"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def minPartitions(self, n: str) -> int:\n",
    "        result = 0\n",
    "        for c in n:\n",
    "            result = max(result, int(c))\n",
    "        return result"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def minPartitions(self, n: str) -> int:\n",
    "        return int(max(n))\n",
    "        \n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def minPartitions(self, n: str) -> int:\n",
    "        res = 0\n",
    "        for c in n:\n",
    "            if int(c) > res:\n",
    "                res = int(c)\n",
    "        return res"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def minPartitions(self, n: str) -> int:\n",
    "        return int(max(n))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def minPartitions(self, n: str) -> int:\n",
    "        return int(max(n))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def minPartitions(self, n: str) -> int:\n",
    "        res = 0\n",
    "        for s in n:\n",
    "            if int(s) > res:\n",
    "                res = int(s)\n",
    "        return res"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def minPartitions(self, n: str) -> int:\n",
    "        return int(max(n))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def minPartitions(self, n: str) -> int:\n",
    "        res = 0\n",
    "        for s in n:\n",
    "            res = max(res,int(s))\n",
    "        return res\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def minPartitions(self, n: str) -> int:\n",
    "        res = 0\n",
    "        for i in n:\n",
    "            if int(i) > res:\n",
    "                res = int(i)\n",
    "        return res"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def minPartitions(self, n: str) -> int:\n",
    "       \n",
    "        return int (max(n)) \n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def minPartitions(self, n: str) -> int:\n",
    "        return int(max(n))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def minPartitions(self, n: str) -> int:\n",
    "        m=0\n",
    "        for i in n:\n",
    "            m=max(m,int(i))\n",
    "        return m"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def minPartitions(self, n: str) -> int:\n",
    "        return int(max(n))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def minPartitions(self, n: str) -> int:\n",
    "        res = 0\n",
    "        for i in n:\n",
    "            if int(i) == 9:\n",
    "                return 9\n",
    "            if int(i) > res:\n",
    "                res = int(i)\n",
    "        return res"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def minPartitions(self, n: str) -> int:\n",
    "        return int(max(n))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def minPartitions(self, n: str) -> int:\n",
    "        return int(max(n))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def minPartitions(self, n: str) -> int:\n",
    "        return int(max(n))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def minPartitions(self, n: str) -> int:\n",
    "        return int(max(n))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def minPartitions(self, n: str) -> int:\n",
    "        ans = 0\n",
    "        for i in n:\n",
    "            if int(i) == 9:\n",
    "                return 9\n",
    "            ans = max(ans,int(i))\n",
    "        return ans"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def minPartitions(self, n: str) -> int:\n",
    "        return int(max(n))\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def minPartitions(self, n: str) -> int:\n",
    "        max_s='0'\n",
    "        for i in n:\n",
    "            if i>max_s:\n",
    "                max_s=i\n",
    "        return int(max_s)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def minPartitions(self, n: str) -> int:\n",
    "        dp = [0] * 10\n",
    "        for ch in n:    dp[int(ch)] += 1\n",
    "        for i in range(9, 0, -1):   \n",
    "            if dp[i] != 0:  \n",
    "                return i"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def minPartitions(self, n: str) -> int:\n",
    "        ###### 本质： 找最大的数字\n",
    "        return int(max(n))\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def minPartitions(self, n: str) -> int:\n",
    "         return ord(max(n)) - ord('0')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def minPartitions(self, n: str) -> int:\n",
    "        \n",
    "        return int(max(n))\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def minPartitions(self, n: str) -> int:\n",
    "        count = 1\n",
    "        for i in n:\n",
    "            count = max(int(i), count)\n",
    "        return count"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def minPartitions(self, n: str) -> int:\n",
    "        res = 1\n",
    "        for c in n:\n",
    "            if ord(c) - 48 > res:\n",
    "                res = ord(c) - 48\n",
    "                if res == 9:\n",
    "                    return res\n",
    "        return res"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "\n",
    "    def minPartitions(self, n: str) -> int:\n",
    "\n",
    "        ###### 本质： 找最大的数字\n",
    "\n",
    "        return int(max(n))\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def minPartitions(self, n: str) -> int:\n",
    "        return int(max(n))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def minPartitions(self, n: str) -> int:\n",
    "        return int(max(n)) "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def minPartitions(self, n: str) -> int:\n",
    "        return int(max(n))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def minPartitions(self, n: str) -> int:\n",
    "        # result = 0\n",
    "        # for c in n:\n",
    "        #     result = max(result, int(c))\n",
    "        #     if(result == 9):\n",
    "        #         break\n",
    "        # return result\n",
    "        for v in range(9,0,-1):\n",
    "            if(str(v) in n):\n",
    "                return v"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "\n",
    "class Solution:\n",
    "    def minPartitions(self, n: str) -> int:\n",
    "        return int(max(n))\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def minPartitions(self, n: str) -> int:\n",
    "        cnt = 0\n",
    "        for ch in n:\n",
    "            cnt = max(cnt, int(ch))\n",
    "        return cnt"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def minPartitions(self, n: str) -> int:\n",
    "        return  int(max(n))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def minPartitions(self, n: str) -> int:\n",
    "        n=str(n)\n",
    "        return int(max(n))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def minPartitions(self, n: str) -> int:\n",
    "        return int(max(n))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def minPartitions(self, n: str) -> int:\n",
    "        res = 0\n",
    "        for x in n:\n",
    "            res = max(res, int(x))\n",
    "        return res"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def minPartitions(self, n: str) -> int:\n",
    "        return int(max(n))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def minPartitions(self, n: str) -> int:\n",
    "      return int(max(n))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def minPartitions(self, n: str) -> int:\n",
    "        return int(max(n))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def minPartitions(self, n: str) -> int:\n",
    "        return int(max(n))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def minPartitions(self, n: str) -> int:\n",
    "        max1 = 0\n",
    "        for i in range(len(n)):\n",
    "            t = int(n[i])\n",
    "            if (t > max1):\n",
    "                max1 = t\n",
    "        return max1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def minPartitions(self, n: str) -> int:\n",
    "        dp = [0] * 10\n",
    "        for ch in n:    dp[int(ch)] += 1\n",
    "        for i in range(9, 0, -1):   \n",
    "            if dp[i] != 0:  \n",
    "                return i"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def minPartitions(self, n: str) -> int:\n",
    "        if '9' in n:\n",
    "            return 9\n",
    "        elif '8' in n:\n",
    "            return 8\n",
    "        elif '7' in n:\n",
    "            return 7\n",
    "        elif '6' in n:\n",
    "            return 6\n",
    "        elif '5' in n:\n",
    "            return 5\n",
    "        elif '4' in n:\n",
    "            return 4\n",
    "        elif '3' in n:\n",
    "            return 3\n",
    "        elif '2' in n:\n",
    "            return 2\n",
    "        else:\n",
    "            return 1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def minPartitions(self, n: str) -> int:\n",
    "        res = 0\n",
    "        for i in n:\n",
    "            if int(i) == 9:\n",
    "                return 9\n",
    "            if int(i) > res:\n",
    "                res = int(i)\n",
    "        return res"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def minPartitions(self, n: str) -> int:\n",
    "        result = 0\n",
    "        for c in n:\n",
    "            result = max(result, int(c))\n",
    "        return result"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def minPartitions(self, n: str) -> int:\n",
    "        return int(max(n))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def minPartitions(self, n: str) -> int:\n",
    "        res = 0\n",
    "        for i in n:\n",
    "            if int(i) == 9:\n",
    "                return 9\n",
    "            if int(i) > res:\n",
    "                res = int(i)\n",
    "        return res"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def minPartitions(self, n: str) -> int:\n",
    "        return int(max(n))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def minPartitions(self, n: str) -> int:\n",
    "        return int(max(n))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def minPartitions(self, n: str) -> int:\n",
    "        return int(max(n))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def minPartitions(self, n: str) -> int:\n",
    "        return max(int(c) for c in n)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def minPartitions(self, n: str) -> int:\n",
    "        result = 0\n",
    "        for c in n:\n",
    "            result = max(result, int(c))\n",
    "            if(result == 9):\n",
    "                break\n",
    "        return result"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def minPartitions(self, n: str) -> int:\n",
    "        a=max(n)\n",
    "        return int(a)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def minPartitions(self, n: str) -> int:\n",
    "        return int(max(n))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def minPartitions(self, n: str) -> int:\n",
    "        return int(max(n))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def minPartitions(self, n: str) -> int:\n",
    "        maxNum = 0\n",
    "        for i in range(0,len(n),1):\n",
    "            num = int(n[i])\n",
    "            if(num>maxNum):\n",
    "                maxNum = num\n",
    "        return maxNum\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def minPartitions(self, n: str) -> int:\n",
    "        return int(max(n)) "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def minPartitions(self, n: str) -> int:\n",
    "        return max(map(int, (num for num in n)))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def minPartitions(self, s: str) -> int:\n",
    "        n = len(s)\n",
    "        ans = 0\n",
    "        return int(max(s))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def minPartitions(self, n: str) -> int:\n",
    "        a = len(n)\n",
    "\n",
    "        count = int(n[0])\n",
    "\n",
    "        if count < 9:\n",
    "            for i in range(1,a):\n",
    "                if int(n[i]) <= count:\n",
    "                    pass\n",
    "                elif int(n[i]) > count:\n",
    "                    count = int(n[i])\n",
    "\n",
    "        return count"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def minPartitions(self, n: str) -> int:\n",
    "        return max(int(digit) for digit in n)\n",
    "\n",
    "# 测试代码\n",
    "sol = Solution()\n",
    "print(sol.minPartitions(\"32\"))  # 输出应为 3\n",
    "print(sol.minPartitions(\"82734\"))  # 输出应为 8\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def minPartitions(self, n: str) -> int:\n",
    "        print(\"n====\",n)\n",
    "        print(\"max(n)\",max(n))\n",
    "        return int(max(n))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def minPartitions(self, n: str) -> int:\n",
    "        mi = 0\n",
    "        for x in map(int,list(n)):\n",
    "            if x > mi : mi = x\n",
    "        return mi\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def minPartitions(self, n: str) -> int:\n",
    "        return int(max(list(n)))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def minPartitions(self, n: str) -> int:\n",
    "        return max(map(int,list(n)))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def minPartitions(self, n: str) -> int:\n",
    "        return int(max(list(n)))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def minPartitions(self, n: str) -> int:\n",
    "        count = 0\n",
    "        n_=list(n)\n",
    "        for i in n_:\n",
    "            if int(i) > count:\n",
    "                count = int(i)\n",
    "        return count"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def minPartitions(self, n: str) -> int:\n",
    "        lst = list(n)\n",
    "        lst.sort()\n",
    "        return int(lst[-1])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def minPartitions(self, n: str) -> int:\n",
    "        return max([int(i) for i in n])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def minPartitions(self, n: str) -> int:\n",
    "        return max([int(x) for x in n])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def minPartitions(self, n: str) -> int:\n",
    "        nums = [int(each) for each in n]\n",
    "        return max(nums)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def minPartitions(self, n: str) -> int:\n",
    "        return int(max([x for x in n]))"
   ]
  }
 ],
 "metadata": {},
 "nbformat": 4,
 "nbformat_minor": 2
}
